<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>图书管理</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
    <link type="text/css" rel="stylesheet" href="static/css/style.css">
</head>
<body>

<jsp:include page="top.jsp"></jsp:include>

<div id="main">
    <table>
        <tr>
            <td>名称</td>
            <td>价格</td>
            <td>作者</td>
            <td>销量</td>
            <td>库存</td>
            <td colspan="2">操作</td>
        </tr>
        <c:forEach items="${requestScope.page.items}" var="book">
            <tr>
                <td>${book.name}</td>
                <td>${book.price}</td>
                <td>${book.author}</td>
                <td>${book.sales}</td>
                <td>${book.stock}</td>
                <td><a href="BookServlet?method=getBook&id=${book.id}&pageNo=${requestScope.page.pageNo}">修改</a></td>
                    <%--                <td><a href="javascript:void(0)" onclick="mydelete('${book.id}')">删除</a></td>--%>
                <td><a class="deleteClass"
                       href="BookServlet?method=delete&id=${book.id}&pageNo=${requestScope.page.pageNo}">删除</a></td>
            </tr>
        </c:forEach>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td><a href="pages/manager/book_edit.jsp">添加图书</a></td>
        </tr>
    </table>

    <!-- 动态包含pageing.jsp网页 -->
    <jsp:include page="/pages/component/paging.jsp"></jsp:include>

</div>
<div id="bottom">
		<span>
			网上书城.Copyright &copy;2020
		</span>
</div>
</body>
</html>
<script src="static/script/jquery-1.7.2.js"></script>
<script>
    $(function () {
        /*
        //最后一页时处理a连接显示的效果
        var pageNo = parseInt($("#pageNo").html());
        var maxPage = parseInt($("#maxPage").html());
        //如果当前页大于等于最大页.就将a连接的href属性删除掉
        if (pageNo >= maxPage) {
            $("a.peiClass").removeAttr("href");
            $("a.peiClass").css("color", "silver");
        }*/


        //删除图书提示方法
        $("a.deleteClass").click(function () {
            var bookName = $(this).parents("tr").find("td:first").html();
            if (window.confirm("你是否要删除《" + bookName + "》?")) {
                return true;
            } else {
                return false;
            }
        });
    });

    /*function mydelete(id) {
        if (window.confirm("确定是否删除数据?")) {
            window.location.href = "BookServlet?method=delete&id=" + id;
        }
    }*/
</script>